package com.api.shopapi.mapper;

import com.api.shopapi.entity.TotalOrderMonth;
import com.api.shopapi.entity.TotalOrderYear;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface TotalOrderYearMapper {



    @Insert("insert into total_order_year" +
            "(" +
            "TotalOrderDayCode,"+
            "Year,"+
            "OrderCount,"+
            "OrderMoney,"+
            "CreateTime,"+
            "BusinessCode"+
            ")" +
            "values" +
            "(" +
            "#{totalOrderDay.TotalOrderDayCode}," +
            "#{totalOrderDay.Year}," +
            "#{totalOrderDay.OrderCount}," +
            "#{totalOrderDay.OrderMoney}," +
            "#{totalOrderDay.CreateTime}," +
            "#{totalOrderDay.BusinessCode}" +
            ")")
    int insert(@Param("totalOrderYear") TotalOrderYear totalOrderYear);

    @Select("select * from total_order_year" +
            " where" +
            " businessCode=#{businessCode} order by CreateTime asc limit 10")
    List<TotalOrderMonth> ListLatest(@Param("businessCode") String businessCode);

}
